using System;
using Slobby.Common;
using Slobby.SharedNetworkTypes;

namespace Slobby.Server {
    public class ServerReciever : Reciever  {
        Client client;
        ClientList list;

        public ServerReciever(Client client, ClientList list) {
            this.client = client;
            this.list = list;
        }

        public void Recieve(SendChatMessage chat) {
            list.SendToAllExcept(client, new RecieveChatMessage(client.Name, chat.Message));
        }

        public void Recieve(HostGameMessage game) {
            JoinGameMessage j = new JoinGameMessage(client.Address.ToString(), game.Port);

            if (j.Address == "127.0.0.1") {
                j.Address = Properties.ServerSettings.Default.localIPOverride;
            }

            list.SendToAllExcept(client, j);
        }

        public override void Default(object o) {
            
        }
    }
}
